-
Notifications
You must be signed in to change notification settings - Fork 8.2k
stm32: pwm driver enables complementary output for timer channel #42119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tested on the nucleo_l4r5zi target where the PB 14 pin which is for the red Led is a output of a PWM signal from
|
79215c2 to
7b95749
Compare
gmarull
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pinctrl information is not meant to be used by drivers directly. If you want PWM to enable complementary output, you should add an additional flag at the pwm node or, propose a new PWM flag. Then user is responsible to set pinctrl appropriately.
IIUC this means that we should be able to identify a PWM channel to a pin. Does it mean that we can rely on the order of the pins established by the user in pins array ? |
|
One option would be to do something like this: |
|
Or, another option (not tested):
|
7b95749 to
034e901
Compare
|
This option is clear and readable to me because it direcly goes to the pwm driver |
034e901 to
97f1998
Compare
|
new version without impact on the pinctrl but only the PWM driver. |
97f1998 to
281104b
Compare
|
splitting in 2 PR:
|
ccb31f5 to
4ec7c99
Compare
drivers/pwm/pwm_stm32.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's define a STM32_MAX_N_CHANNEL constant and use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Maximum number of complemented timer channels. */
#define STM32_MAX_N_CHANNEL 4
50d1c45 to
c554e96
Compare
65cd39d to
3d29d57
Compare
Codecov Report
@@ Coverage Diff @@
## main #42119 +/- ##
=======================================
Coverage 49.52% 49.52%
=======================================
Files 634 634
Lines 79487 79487
Branches 18588 18588
=======================================
Hits 39364 39364
Misses 33621 33621
Partials 6502 6502 Continue to review full report at Codecov.
|
3d29d57 to
8685a07
Compare
|
using stm32Cube LL definition to detect the Max nb of timer channels, to define the table of complementary channels |
a40f924 to
005a2e3
Compare
Add 8 bits to the pwm_flags_t so that upper byte is reserved for non-standard but soc specific dts flags and keeping the low Byte for standard flags. Some of SoC like STM32 mcus can then define their own flags in their dt-bindings/pwm. Signed-off-by: Francois Ramu <[email protected]>
005a2e3 to
9004b1b
Compare
Depending on the stm32 soc and the timer instance, several channels can enable the complementary output for the PWM signal This flag completes the PWM_POLARITY for a PWM channel in the upper byte of the pwm_flags_t. Signed-off-by: Francois Ramu <[email protected]>
9004b1b to
1c74cc7
Compare
ABOSTM
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Depending on the stm32 mcus and the timer instance, several channels can enable the complementary output for the PWM signal. Example of a DTS <&pwm1 2 4 (PWM_POLARITY_NORMAL | PWM_COMPLEMENTARY)>; Note that the timer channel must support the complementary output on that channel : usually channels 1-3 + channel 4 on stm32g4x. Signed-off-by: Francois Ramu <[email protected]>
If the dts defines the PWM complementary output, then the OCN must be init in place of the OC state and polarity. This is an exclusive setting for this pin. The channel in LL_TIM_OC_SetPolarity can be the complementary one. Signed-off-by: Francois Ramu <[email protected]>
Adding an overlay to configure the nucleo_l4r5zi for testing the pwm blinky application on red led (PB14 on nucleo board) Each has a specific pwm output from different timers/channels Signed-off-by: Francois Ramu <[email protected]>
1c74cc7 to
1498c36
Compare
|
Can #42174 be closed in favour of this PR? |
with this PR, the complementary PWM output is enabled when the pin is choosen in the DTS of the target
Using a newly defined PWM_COMPLEMENTARY flag in the target board DTS as follows:
Fixes #40657
Signed-off-by: Francois Ramu [email protected]